import Request from 'luch-request'
import { BASE,ID,KEY } from '../config'
const request = new Request()

request.config.baseURL = BASE+'/1.1/'
request.config.header = {
	'X-LC-Id':ID,
	'X-LC-Key':KEY,
	'content-type':'application/json'
}
request.interceptors.request.use((config) => { // 可使用async await 做异步操作
  config.header = {
    ...config.header,
  }
  return config
}, config => { // 可使用async await 做异步操作
  return Promise.reject(config)
})

request.interceptors.response.use((response) => { /* 对响应成功做点什么 可使用async await 做异步操作*/
  return response
}, (response) => { /*  对响应错误做点什么 （statusCode !== 200）*/
  console.log(response)
  return Promise.reject(response)
})
export default request
